
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false" %>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/examproject/manage/css/layui.css" media="all">
    <link rel="stylesheet" href="/examproject/manage/css/admin.css" media="all">
    <link id="layuicss-layer" rel="stylesheet" href="/examproject/manage/css/layer.css" media="all"><link id="layuicss-laydate" rel="stylesheet" href="/schoolexam/css/laydate.css" media="all"></head>
<style>
    .cur{
        font-family:宋体;
        font-size:20px;
        line-height:30px;
        color:palevioletred;
        etter-spacing: 50px;
    }
    .cur2{
        font-family:楷体;
        font-size:26px;
        line-height:30px;
        color:black;
        etter-spacing: 50px;
    }
    fieldset, ol ,li{
        padding:0;
        margin:0;
    }
    ol{
        list-style:none;
    }
    body{
        background:#fff;
        color:#111;
        padding:20px;
    }
    form#payment{
        background:#00ffff;
        -webkit-border-radius:5px;
        border-radius:5px;
        padding:20px;
        width:400px;
    }
    form#payment fieldset{
        border:none;
        margin-bottom:10px;
    }
    form#payment fieldset:last-of-type{ margin-bottom:0; }
    form#payment legend{
        color:#384313;
        font-size:16px;
        font-weight:bold;
        padding-bottom:10px;
        text-shadow:0px 1px 1px #c0d576;
    }
    form#payment > fieldset>legend:before{
        content:"Step" counter(fieldset)":";
        counter-increment:fieldsets;
    }
    form#payment fieldset fieldset legend{
        color:#111;
        font-size:13px;
        font-weight:normal;
        padding-bottom:0;
    }
    form#payment ol li{
        background:#b9cf6a;
        background:rgba(255, 255, 255, 0.3);
        border:#e3ebc3;
        border-color:rgba(255, 255, 255, 0.6);
        border-style:solid;
        border-width:2px;
        -webkit-border-radius:5px;
        line-height:30px;
        padding:5px 10px;
        margin-bottom:2px;
    }
    form#payment ol ol li{
        bakcground:none;
        border:none;
        float:left;
    }
    form#payment label{
        float:left;
        font-size:17px;
        width:110px;
    }
    form#payment fieldset fieldset label{
        background:none no-repeat left 50%;
        line-height:20px;
        padding:0 0 0 30px;
        width:auto;
    }
    form#payment fieldset fieldset label:hover{cursor:pointer;}
    form#payment input:not([type=radio]), form#payment textarea{
        background:#fff;
        border:#fc3 solid 1px;
        -webkit-border-radius:3px;
        outline:none;
        padding:5px;
    }
    * {
        margin: 0;
        padding: 0;
    }

    .mydiv{
        position:absolute;
        left:50%;
        top:50%;
        margin-left:-200px;
        margin-top:-130px;
        display:none;
    }

</style>

<body>
<div class="layui-fluid">
    <div class="layui-col-md12">
        <div class="layui-navs">
					<span class="layui-breadcrumb" lay-separator="—" style="visibility: visible;">
						<a href="">系统设置</a><span lay-separator="">—</span>
						<a href="j">管理员设置</a><span lay-separator="">—</span>
						<a><cite>管理员列表</cite></a>
					</span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;float:right;height: 36px;" href="javascript:location.replace(location.href);" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:36px;font-size: 16px;"></i>
            </a>
        </div>
    </div>
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body ">
                <form class="layui-form layui-col-space5" id="myfo" action="/examproject/man/find" method="post">
                    <div class="layui-inline layui-show-xs-block">
                        <input type="text" name="name" id="mydj" placeholder="请输入名称" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline layui-show-xs-block">
                        <button class="layui-btn" onclick="obtn()"  type="submit"  lay-submit="" lay-filter="sreach"  ><i class="layui-icon"></i></button>
                    </div>
                </form>
                <form class="layui-form layui-col-space5" id="myfo2" id="myfo2" action="/examproject/man/find2" method="post">
                    <div class="layui-inline layui-show-xs-block">
                        <input type="text" name="name2" id="mydj2" placeholder="请输入职位" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline layui-show-xs-block">
                        <button class="layui-btn" onclick="obtn2()" type="submit"  lay-submit="" lay-filter="sreach"  ><i class="layui-icon"></i></button>
                    </div>
                </form>
            </div>
            <div class="layui-card-header">
                <button class="layui-btn" type="submit" onclick="ondiv()">添加老师</button>
            </div>
            <div id="mytb1">
                <table class="layui-table layui-form"  id="tab">
                    <tr>
                        <th>老师ID</th>
                        <th>名称</th>
                        <th>密码</th>
                        <th>电话</th>
                        <th>职位</th>
                        <th>管理</th>
                    </tr>
                    <c:forEach items="${tclist }" var="t">
                        <tr>
                            <td>${t.teacherId}</td>
                            <td>${t.tname}</td>
                            <td>${t.tpass}</td>
                            <td>${t.tphone}</td>
                            <td>${t.tjob}</td>
                            <td>                                                                    <%--:href="abc.html?param1=val1&parm2=val2¶m3=3--%>
                                <a class="layui-btn layui-btn-sm layui-btn-normal" id="xg" title="编辑" onclick="ondiv1()" ><i class="layui-icon layui-icon-edit"></i>编辑</a>
                                <a class="layui-btn layui-btn-sm layui-btn-danger" title="删除"  href="/examproject/man/delete?name=${t.tname }" onclick="return confirm('确定要删除吗 ?')"><i class="layui-icon layui-icon-delete"></i>删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                </table>
                <c:choose>
                    <c:when test="${tclist!='[]'}">
<div align="center">
                <a  class='cur' href="/examproject/man/getPage?p=1">首页</a>
                <c:if test="${pb.curpage>1 }">
                    <a  class='cur' href="/examproject/man/getPage?p=${pb.curpage-1}">上一页</a>
                </c:if>
                <c:forEach begin="${pb.begin}" end="${pb.end}" var="k">
                    <c:if test="${k==pb.curpage }">
                        <a class='cur2' href="/examproject/man/getPage?p=${k}">${k}</a>
                    </c:if>
                    <c:if test="${k!=pb.curpage }">
                        <a  class='cur' href="/examproject/man/getPage?p=${k}">${k}</a>
                    </c:if>
                </c:forEach>
                <c:if test="${pb.curpage<pb.end}">
                    <a  class='cur' href="/examproject/man/getPage?p=${pb.curpage+1}">下一页</a>
                </c:if>
                <a  class='cur' href="/examproject/man/getPage?p=${pb.pages }">尾页</a>
</div>
                    </c:when>
                    <c:otherwise>
                        <h1 align="center">未找到相关信息</h1>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
    </div>
</div>

<%--添加div--%>
<div class="mydiv" id="mydiv" >
    <form action="/examproject/man/addtc" method="post" id=payment>
        <fieldset>
            <a class="gb" href="#" style="width:100%; margin-left:99%;margin-right:0%;height: 10px">X</a>
            <ol>
                <li>
                    <label >名称:</label>
                    <input type="text" id="text" name="name" required >
                </li>
                <li>
                    <label >密码:</label>
                    <input type="text" name="pwd" required>
                </li>
                <li>
                    <label >电话:</label>
                    <input type="text"  name="phone" required>
                </li>
                <li>
                    <label >职位:</label>
                    <input type="text"  name="job" required>
                </li>
            </ol>
        </fieldset>
        <fieldset align="center">
        <button type="submit" onclick="but()">添加</button>
        </fieldset>
    </form>
</div>

<%--修改div--%>
<div class="mydiv" id="mydiv1" >
    <form action="/examproject/man/updatetc" method="post" id=payment class='myfm'>
        <fieldset>
            <a class="gb1" href="#" style="width:100%; margin-left:99%;margin-right:0%;height: 10px">X</a>
            <ol>
                <li>
                    <label >ID:</label>
                    <input type="text"  name="id" readonly="readonly" required>
                </li>
                <li>
                    <label >名称:</label>
                    <input type="text"  name="name" required>
                </li>
                <li>
                    <label >密码:</label>
                    <input type="text"  name="pwd" required>
                </li>
                <li>
                    <label >电话:</label>
                    <input type="text"  name="phone"  required >
                </li>
                <li>
                    <label >职位:</label>
                    <input type="text"  name="job" required>
                </li>
            </ol>
        </fieldset>
        <fieldset align="center">
            <button type="submit"  >修改</button>
        </fieldset>
    </form>
</div>


<script>
    var msg =<%=request.getParameter("msg")%>;
    if(msg==true){
        alert("该用户已存在");
    }else if(msg==false){
        alert("电话号码不能超过11位")
    }
    function ondiv1() {
       // document.getElementById("mydiv1").style.display = "block";
        var mydiv =document.querySelector("#mydiv1");
        var as = document.querySelectorAll("#xg");
        for(var i =0;i<as.length;i++){
            as[i].onclick=function(){
                console.log(this);
                mydiv.style.display='block';
                var tr=this.parentNode.parentNode;
                var tds=tr.children;
                var inps=document.querySelectorAll(".myfm input");
                for(var k=0;k<5;k++){
                    inps[k].value=tds[k].innerHTML;
                }
                console.log(tr);
            }
        }

    }

    function obtn(){
        var a=document.getElementById("mydj").value;
       if (a==""){
            var myfo=document.getElementById("myfo");
            myfo.action="/examproject/man/getPage";
        }
    }

    function obtn2(){
        var a=document.getElementById("mydj2").value;
        if (a==""){
            var myfo=document.getElementById("myfo2");
            myfo.action="/examproject/man/getPage";
        }
    }


    window.onload=function() {
        /*添加*/
        var mydiv = document.querySelector(".mydiv");
        var gba = document.querySelector(".gb");
        gba.onclick = function () {
            mydiv.style.display = 'none';
        }
    }
    function ondiv(){
        document.getElementById("mydiv").style.display="block";
    }

    /*修改*/
    var gba = document.querySelector(".gb1");
    gba.onclick = function () {
        mydiv1.style.display = 'none';
    }
</script>
</body>
</html>
